package com.atguigu.flink.streamapi.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**

 */
public class Demo2_FromFile
{
    public static void main(String[] args) {
        
      StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

      env.setParallelism(1);

       //可以是一个目录也可以是一个具体的文件
        //DataStreamSource<String> ds = env.readTextFile("data");

        /*
            也可以是一个远程的文件

            UnsupportedFileSystemSchemeException: Hadoop is not in the classpath/dependencies.
                    在类路径下引入 hadoop-client

                    默认读取utf-8格式数据
         */
        DataStreamSource<String> ds = env.readTextFile("hdfs://hadoop102:9820/input");


        ds.print();

        try {
          env.execute();
      } catch (Exception e) {
          e.printStackTrace();
      }

    }
}
